import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';

// 批量加载
const modules = import.meta.glob('./**/*.ts', { eager: true, import: 'default' });

const mockModules: any[] = [];
Object.keys(modules).forEach((key) => {
  if (key.includes('/_')) {
    return;
  }
  const mod = modules[key] || {}
  const modList = Array.isArray(mod) ? [...mod] : [mod]
  mockModules.push(...modList);
});

/**
 * Used in a production environment. Need to manually import all modules
 */
export function setupProdMockServer() {
  createProdMockServer(mockModules);
}